﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using System.Drawing;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace ImplementationJeu
{
    public class Serialization
    {
        //Serialization
        public static void sauvegarderPartie(string filename)
        {
            FileStream file = File.Open(filename, FileMode.Create);
            IFormatter formatter = new BinaryFormatter();
            Jeu jj = ImplementationJeu.Jeu.Instance;
            formatter.Serialize(file, jj);
            file.Close();
        }

        //Deserialization
        public static void chargerPartie(string filename)
        {
            FileStream file = File.Open(filename, FileMode.Open);
            IFormatter formatter = new BinaryFormatter();
            Jeu j = (Jeu)formatter.Deserialize(file);
            file.Close();
            ImplementationJeu.Jeu.Instance = j;
        }
    }
}
